import java.util.Scanner;
import java.util.Stack;

public class Main1 {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        String s = in.next();
        System.out.println(func(s));
    }

    private static boolean func(String s) {
        Stack<Character> stack = new Stack<>();
        int i = 0;
        int len = s.length();
        while (i < len) {
            char c = s.charAt(i);
            if (c == '(' || c == '<') {
                stack.push(c);
            } else {
                if (stack.isEmpty()) return false;
                char prev = stack.pop();
                if (c == ')' && prev != '(') {
                    return false;
                } else if (c == '>' && prev != '<') {
                    return false;
                }
            }
            i++;
        }
        return true;
    }
}
